Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
What is this PR
Why is this PR needed?
We recently implemented a linting/code formatting overhaul, relying on
ruff
#156.However, we are still missing linting/formatting for docstrings. Would be nice to have them all formatted in a uniform way.
What does this PR do?
It adds the "D" (pydocstyle) ruleset to the
ruff
config.That enforces a bunch of rules on docstring formatting, and most problems are auto-fixed.
However, I had to fix lots of issues manually, because many of our existing docstrings were non-compliant.
The rules that necessitated most manual work were the ones stipulating that docstrings should start with a one-line short description ending in a period, optionally followed by a longer description (separated from the one-liner by 1 blank line), e.g.:
This is a bit restrictive and I had to rewrite a bunch of docstrings accordingly, but I like the consistent result we end up with.
Going forward this should be much less work, because we'll get immediate feedback on this via
pre-commit
, so no additional inconsistencies should creep in.I relaxed the rules quite a bit for the
tests
folder, because those docstrings are not public-facing.The relevant configuration changes are to be found in
pyproject.toml
. All the other diffs have to do with fixing issues encountered duringpre-commit run --all-files
.How has this PR been tested?
Visually checked the locally rendered sphinx API docs.
Is this a breaking change?
No.
Does this PR require an update to the documentation?
No.
Checklist: